package sunwin.yoms.comm.model;

import jodd.datetime.JDateTime;

import java.sql.Time;
import java.util.Date;

/**
 * Created by mt on 2015-9-17.
 */
public class TimeSpan {
    private Date startTime = new JDateTime(1970, 1, 1).convertToDate();
    private Date endTime = new JDateTime(1970, 1, 1).convertToDate();

    public Time getStartTime() {
        return new JDateTime(startTime).convertToSqlTime();
    }

    public void setStartTime(Time startTime) {
        this.startTime = startTime;
    }

    public Time getEndTime() {
        return new JDateTime(endTime).convertToSqlTime();
    }

    public void setEndTime(Time endTime) {
        this.endTime = endTime;
    }

    /*Time String*/
    public String getStartTimeString() {
        return new JDateTime(startTime).toString("hh:mm");
    }

    public void setStartTimeString(String startTime) {
        this.startTime = new JDateTime("1970-01-01 " + startTime).convertToDate();
    }

    public String getEndTimeString() {
        return new JDateTime(endTime).toString("hh:mm");
    }

    public void setEndTimeString(String endTime) {
        this.endTime = new JDateTime("1970-01-01 " + endTime).convertToDate();
    }

    @Override
    public String toString() {
        return this.getStartTimeString() + "-" + this.getEndTimeString();
    }
}